<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
     
      var f1;
      function outer() {
        var num = 0;

        function inner() {
          num++;

          console.log(num);
        }

        return inner;
      }

      f1 = outer();

      f1();

      f1();

      var f2 = outer();

      f2();

      f2();
    </script>
  </body>
</html>
